//
//  BaseTableViewController.swift
//  weibo
//
//  Created by 张宏芝 on 15/8/31.
//  Copyright © 2015年 kama. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {

    let userLogon = UserAccountViewModel.sharedUserAccount.userLogon
//    let userLogon = true
//    let userLogon = false
    
    var visitorView:visitorLoginView?
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
    }
    
//    判断是不是登陆状态,不是登陆状态就进入setupVistor页面
    override func loadView() {
        userLogon ? super.loadView() : setupVistorView()
    }
    
    private func setupVistorView() {
       
        visitorView  = visitorLoginView()
       
        view = visitorView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        visitorView?.registerButton.addTarget(self, action: "visitorLoginViewWillRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "visitorLoginViewWillLogin", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
   
     func visitorLoginViewWillRegister(){
        print("点击注册按钮了")
    }
     func visitorLoginViewWillLogin(){
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        
    }

}
